<!DOCTYPE html>
<html lang="cn">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style type="text/css"></style>
</head>
<body>
    <h1>location</h1>
    <hr>

    <button onclick="location.reload()">刷新</button>

    <!-- 如果使用JS 跳转指定页面 -->
    <button onclick="location.replace('http://163.com')">replace</button>
    <button onclick="location.assign('http://taobao.com')">assign</button>
    <button onclick="location.href = 'http://126.com'">href</button>
    

    <script>
    // console.log(location);
    console.log( 'URL: '+ location.href);

    console.log('协议: '+ location.protocol);
    console.log('域名/主机名: '+ location.hostname);
    console.log('主机名+端口号: '+ location.host);
    console.log('路径 '+ location.pathname);
    console.log('参数 '+ location.search);
    console.log('锚点 '+ location.hash);

    // location.href = 'http://www.huaban.com';
    // location.search = '?age=18';
    // location.hash = '#p100';
    

    </script>
</body>
</html>